home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWOSMisc / Include / FWTime.h < prev   
Encoding:
Text File  |  1995-11-08  |  3.7 KB  |  133 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWTime.h
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1993, 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #if !defined(FWTIME_H) && !defined(__ODFRC__)
  11. #define FWTIME_H
  12.  
  13. #ifndef FWSTDDEF_H
  14. #include "FWStdDef.h"
  15. #endif
  16.  
  17. #if defined(FW_BUILD_MAC) && !defined(__TIME_H__)
  18. #include <Time.h>
  19. #endif
  20.  
  21. #if defined(FW_BUILD_MAC) && !defined(__OSUTILS__)
  22. #include <OSUtils.h>
  23. #endif
  24.  
  25. #if defined(FW_BUILD_WIN) && !defined(__TIME_H__)
  26. #include <Time.h>
  27. #endif
  28.  
  29. #if FW_LIB_EXPORT_PRAGMAS
  30. #pragma lib_export on
  31. #endif
  32.  
  33. //========================================================================================
  34. //    Forward Class Declarations
  35. //========================================================================================
  36. class FW_CLASS_ATTR FW_CTimeSpan;
  37. class FW_CLASS_ATTR FW_CString;
  38.  
  39. //========================================================================================
  40. //    FW_CTime
  41. //========================================================================================
  42.  
  43. class FW_CLASS_ATTR FW_CTime
  44. {
  45. public:
  46.     enum  DateForm { kShortDate, kLongDate, kAbbreviatedDate};
  47.     
  48.     FW_CTime();
  49.     FW_CTime(time_t theTime);
  50.     FW_CTime(const FW_CTime& theTime);
  51.     FW_CTime(short year, short month, short day, short hour, short minute, short second, short dayOfWeek);
  52.     ~FW_CTime();
  53.     
  54.     static FW_CTime GetCurrentTime();    // Create a new time initialized to the current time
  55.     
  56.     // Accessors
  57.     time_t GetTime() const;
  58.     
  59.     short GetSecond() const;
  60.     short GetMinute() const;
  61.     short GetHour() const;
  62.     short GetDayOfWeek() const;
  63.     short GetDayOfMonth() const;
  64.     short GetDayOfYear() const;
  65.     short GetMonth() const;
  66.     short GetYear() const;
  67.     short IsDaylightSavings() const;
  68.     
  69.     void GetTimeString(FW_CString& timeString, FW_Boolean displaySeconds) const;
  70.     void GetDateString(FW_CString& dateString, DateForm form) const;
  71.     
  72.     const FW_CTime&     operator=(const FW_CTime& source);
  73.     const FW_CTime& operator=(time_t source);
  74.     
  75.     FW_CTime operator-(FW_CTimeSpan timeSpan) const;
  76.     FW_CTimeSpan operator-(FW_CTime time) const;
  77.     FW_CTime operator+(FW_CTimeSpan timeSpan) const;
  78.     const FW_CTime& operator-=(FW_CTimeSpan timeSpan);
  79.     const FW_CTime& operator+=(FW_CTimeSpan timeSpan);
  80.  
  81.     FW_Boolean operator==(FW_CTime time) const;
  82.     FW_Boolean operator!=(FW_CTime time) const;
  83.     FW_Boolean operator<(FW_CTime time) const;
  84.     FW_Boolean operator>(FW_CTime time) const;
  85.     FW_Boolean operator<=(FW_CTime time) const;
  86.     FW_Boolean operator>=(FW_CTime time) const;
  87.     
  88. private:
  89.     time_t fTime;
  90. };
  91.  
  92. class FW_CLASS_ATTR FW_CTimeSpan
  93. {
  94. public:
  95.     FW_CTimeSpan();
  96.     FW_CTimeSpan(time_t theTimeSpan);
  97.     FW_CTimeSpan(const FW_CTimeSpan& theTimeSpan);
  98.     FW_CTimeSpan(long days, short hours, short minutes, short seconds);
  99.     ~FW_CTimeSpan();
  100.     
  101.     short    GetSeconds() const;
  102.     short    GetMinutes() const;
  103.     short    GetHours() const;
  104.     long    GetDays() const;
  105.     
  106.     long    GetTotalSeconds() const;
  107.     long    GetTotalMinutes() const;
  108.     long    GetTotalHours() const;
  109.     
  110.     const FW_CTimeSpan&    operator=(const FW_CTimeSpan& source);
  111.     const FW_CTimeSpan& operator-=(FW_CTimeSpan timeSpan);
  112.     const FW_CTimeSpan& operator+=(FW_CTimeSpan timeSpan);
  113.  
  114.     FW_CTimeSpan operator-(FW_CTimeSpan timeSpan) const;
  115.     FW_CTimeSpan operator+(FW_CTimeSpan timeSpan) const;
  116.     
  117.     FW_Boolean operator==(FW_CTimeSpan timeSpan) const;
  118.     FW_Boolean operator!=(FW_CTimeSpan timeSpan) const;
  119.     FW_Boolean operator<(FW_CTimeSpan timeSpan) const;
  120.     FW_Boolean operator>(FW_CTimeSpan timeSpan) const;
  121.     FW_Boolean operator<=(FW_CTimeSpan timeSpan) const;
  122.     FW_Boolean operator>=(FW_CTimeSpan timeSpan) const;
  123.  
  124. private:
  125.     long fTotalSeconds;
  126. };
  127.  
  128. #if FW_LIB_EXPORT_PRAGMAS
  129. #pragma lib_export off
  130. #endif
  131.  
  132. #endif
  133.